package com.qiuzhi.service;

import com.qiuzhi.spring.annotations.Aspect;
import com.qiuzhi.spring.annotations.Autowired;
import com.qiuzhi.spring.annotations.Component;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;


@Component
@Aspect("userService")
public class WebLogAspect implements InvocationHandler {

    @Autowired
    private IUserService userService;

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("代理" + method.getName() + "方法");
        Object result = method.invoke(userService, args);
        System.out.println(method.getName() + "方法执行后");
        return result;
    }
}
